#include<iostream>
#include<future>
#include<thread>

int Add(int num1,int num2)
{
    std::cout<<"Add action!!!!"<<std::endl;
    return num1+num2;
}

int main()
{
    // std::future<int> res = std::async(std::launch::deferred,Add,11,22);
    // std::this_thread::sleep_for(std::chrono::seconds(1));
    // std::cout<<"================================"<<std::endl;
    // std::cout<<res.get()<<std::endl;
    auto task=std::make_shared<std::packaged_task<int(int,int)>>(Add);

    std::future<int> res=task->get_future();

    std::thread thr([task](){
        (*task)(11,22);
    });

    std::cout<<res.get()<<std::endl;
    // task(11,22);
    thr.join();
    return 0;
}